package com.kyd.push.common.enums;

import java.util.Objects;

/**
 * EnumKit
 *
 * @author kejw on 2018/8/23
 */
public class EnumKit {

	public static <T extends ValueEnum> T forValue(Object value, Class<T> enumClass) {
		for (T each : enumClass.getEnumConstants()) {
			if (Objects.equals(value, each.value())) {
				return each;
			}
		}

		throw new RuntimeException("无效的枚举值 " + value.toString());
	}

}
